import React, { Component } from "react"
import { View } from '@tarojs/components'
import Taro from '@tarojs/taro'
import GoodsLists from "../../components/GoodsLists"
import { URL } from '../../utils/request'

import './index.scss'

export default class Index extends Component {

  state = {
    goods: []
  }

  componentDidMount() {
    Taro.request({
      method: 'POST',
      url: `${URL}api/goods_lists`,
      data: {},
      header: {
        'content-type': 'application/json' // 默认值
      }
    }).then(res => {
      this.setState({
        goods: res.data.data
      });
    });
  }

  render() {
    const { goods } = this.state;
    return <View className='goods-box'>
      <GoodsLists goods={goods} setShow={this.setShow} />
    </View>
  }
}
